<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 给定任意二维数组，输出所有的排列组合项。
    // 比如 [['A','B'], ['a','b'], [1, 2]]，输出 ['Aa1','Aa2','Ab1','Ab2','Ba1','Ba2','Bb1','Bb2']
    function getCombinations(arr){
        return arr.reduce((acc,cur)=>{
            if (acc.length === 0) {
                return cur
            }
            let temp = []
            acc.forEach(a => {
                cur.forEach(b => {
                    temp.push(`${a}${b}`)
                })
            })
            return temp
        },[])
    }
    const arr = [['A','B'], ['a','b'], [1, 2]]
    console.log(getCombinations(arr));
    
</script>
</html>